//
//  DateToMinutesSecondsValueTransformer.m
//  EVE Mac Suite
//
//  Created by Vadim Lozko on 4/17/09.
//  Copyright 2009  __Vadim__. All rights reserved.
//

#import "DateToMinutesSecondsValueTransformer.h"
#import "EMSSkillTrainingInfo.h"

@implementation DateToMinutesSecondsValueTransformer

+ (Class)transformedValueClass
{
	return [NSString class];
}

+ (BOOL)allowsReverseTransformation
{
    return NO;
}

- (id)transformedValue:(id)value
{
	if(value == nil) return @"";
	NSTimeInterval seconds = [(NSDate*)value timeIntervalSinceDate:[NSDate date]];
	if(seconds < 0)
	{
		return @"00:00";
	}
	HumanNotationTime time = [EMSSkillTrainingInfo humanNotationTimeFromTimeInterval:seconds];
	return [NSString stringWithFormat:@"%02i:%02i", time.minutes, time.seconds];
}

@end
